
/************LucVo************/
var xmlHttp;
var DEFAULT_ROW_PAGING = 35;

var queryString;//giu thong tin cua Post data
var clickedRow = new Array();
clickedRow.rowId = "";
clickedRow.rowColor = "";

function getXmlHttpObject()
{
	var xmlHttp = null;
	try
	{
		//Firefox, Opera 8+, Safari, Chrome
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		//Internet Explorer
		try
		{
			//Internet Explorer 6.0+
			xmlHttp = new ActiveXObject("Msxm12.XMLHTTP");
		}
		catch(e)
		{			
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");			
		}
	}
	
	return xmlHttp;
}

function ajaxFunction(){
	var ajaxRequest;

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				//browsers all not support, rare case
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}

function storeClickedRow(row){	
	//Trả lại màu cho dòng vừa click trước đó
	if(clickedRow.rowId){		
		changeColorClickedRow(document.getElementById(clickedRow.rowId),"");
	}
	
	//lấy id cho dòng vừa đưa vào
	clickedRow.rowId = row.id;			
	
	//đổi màu cho dòng vừa click
	changeColorClickedRow(row,"#FFCCCC")
}

function changeColorClickedRow(row,color){			
	row.style.backgroundColor = color;
};


function getLastPage(){
//	showLayer("page"+(page-1)+",2");
	showLayer("page"+(page-1),'last');
}

function getFirstPage(){
	showLayer("page1",'first');
}


//Ham remove '.00' & ','
function returnNumber(value){
	
	value = value.replace('.00', "");
	value = value.replace(/,/g, "");
	value = parseFloat(value);
	return value;
}

/*
	* Function use to change cursor from wait <=> default
	* Input type = "wait" || type = "default"
*/
function changeCursor(type)
{	
	if(type=="wait"){
		document.getElementsByTagName("body")[0].style.cursor = "wait";
	}else if(type=="default"){
		document.getElementsByTagName("body")[0].style.cursor = "default";
	}	
}

function disabledElement(id)
{
	document.getElementById(id).disabled = true;
}

function enabledElement(id)
{
	document.getElementById(id).disabled = false;
}

function displayElement(id,property)
{
	document.getElementById(id).style.display = property;
}

//Add commas into a number
// 2000000 => 2,000,000
function addCommas(nStr)
{

	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function trim(str)
{
	var start = 0;
	var end = str.length;
	while (start < str.length && str.charAt(start) == ' ') start++;
	while (end > 0 && str.charAt(end-1) == ' ') end--;
	return str.substr(start, end-start);
}